package io.litchi.auth.domain.entity.auth;

import io.litchi.common.base.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.FieldDefaults;
import org.hibernate.annotations.Comment;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * description: 用户
 *
 * @author helang
 * @since 2025-09-16
 */
@EqualsAndHashCode(callSuper = false, of = "id")
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Data
@ToString
@FieldDefaults(level = AccessLevel.PRIVATE)
@Table(name = "user", indexes = {
        @Index(name = "IDX_NICKNAME", columnList = "nickname")
})
@Comment("用户信息表")
public class User extends BaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false, columnDefinition = "BIGINT(24) COMMENT '用户ID'")
    Long id;

    @Column(name = "username", unique = true, nullable = false, columnDefinition = "VARCHAR(20) COMMENT '账号'")
    String username;

    @Column(name = "password", columnDefinition = "VARCHAR(128) COMMENT '密码'")
    String password;

    @Column(name = "nickname", unique = true, columnDefinition = "VARCHAR(256) COMMENT '昵称'")
    String nickname;

    @Column(name = "mobile", columnDefinition = "VARCHAR(128) COMMENT '手机号'")
    String mobile;

    @Column(name = "email", columnDefinition = "VARCHAR(128) COMMENT '邮箱'")
    String email;

    @Column(name = "gender", columnDefinition = "TINYINT COMMENT '性别 0女 1 男 2未知'")
    Integer gender;

    @Column(name = "birthday", columnDefinition = "DATE COMMENT '出生日期'")
    LocalDate birthday;

    @Column(name = "clientId", columnDefinition = "VARCHAR(128) COMMENT '客户端id 预留字段'")
    String clientId;

    @Column(name = "last_login_date", columnDefinition = "DATETIME COMMENT '上次登录时间'")
    LocalDateTime lastLoginDate;

    @Column(name = "open_id", columnDefinition = "VARCHAR(256) COMMENT '微信openId'")
    String openId;

    @Column(name = "status", columnDefinition = "INT default(1) COMMENT '状态'")
    Integer status;


}